package com.dreem.factory.simplefactory.pizzastore.service;

import com.dreem.factory.simplefactory.pizzastore.pizza.Pizza;
import com.dreem.factory.simplefactory.pizzastore.pizza.PizzaProvide;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @program: DesignParrtern
 * @description: 点餐
 * @author: Peng
 * @create: 2021-01-24  10:47
 **/
public class OrderPizza {
    private static PizzaProvide pizzaProvide = PizzaProvide.getInstance();
    private String typeName = "pizza";
    private List<Pizza> pizzaCount = new ArrayList<>();

    private Pizza orderPizza(){
        return pizzaProvide.providePizza(typeName);
    }

    private void setTypeName(){
        System.out.println("请输入想订购的披萨：");
        Scanner orderType = new Scanner(System.in);
        typeName = orderType.nextLine();
    }
    public void makeMenu(){
        while(!typeName.equalsIgnoreCase("exit")){
            this.setTypeName();
            Pizza pizza = this.orderPizza();
            if (pizza != null){
                pizzaCount.add(pizza);
            }
        }
    }
    public void printMenu(){
        System.out.println("----------订单状态----------");
        if(!pizzaCount.isEmpty()){
            for(Pizza pizza : pizzaCount){
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
                System.out.println("+-------------------------+");
            }
        }
    }
}
